import { createRouter, createWebHistory } from 'vue-router'

import LoginView from '@/views/login/index.vue'
import RegisterView from '@/views/register/index.vue'
import HomeView from '@/views/Home/index.vue'
import IndexView from "@/views/Home/home.vue"
import CartView from "@/views/Home/cart.vue"
import classView from "@/views/Home/class.vue"
import MyView from "@/views/Home/my.vue"
import SearchView from '@/views/search/index.vue'
import DetailhView from '@/views/Detail/index.vue'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
     { path: '/', redirect: '/home/home' },
    {
      path: '/login',
      component: LoginView,
    },
    {
      path: '/register',
      component: RegisterView,
    },
     {
      path: '/search',
      component: SearchView,
    },
     {
      path: '/detail/:goods_id',
      component: DetailhView,
    },
    {
      path: '/home',
      component: HomeView,
      children: [
        {
          path: 'home',
          component: IndexView,
        },
        
        {
          path: 'cart',
          component: CartView,
        },
        {
          path: 'class',
          component: classView,
        },
        {
          path: 'my', // 访问的路径
          component: MyView, // 组件名称
        },
      ]
    },
  ],
})

export default router
